/*
 * @Author: zjj
 * @Date: 2020-02-19 09:33:05
 * @LastEditors: zjj
 * @LastEditTime: 2020-02-19 09:33:06
 */
~function () {
    let docEl = document.documentElement;
    // set 1rem = viewWidth / 10
    // 设置root元素的fontSize = 其clientWidth / 10 + ‘px’
    function setRemUnit() {
        var rem = docEl.clientWidth / 10
        let real_font=parseFloat(window.getComputedStyle(document.getElementsByTagName("html")[0]).fontSize.split('p')[0])
        //检测部分华为手机fontsize问题
        if(real_font*120*100<rem*10000){
            docEl.style.fontSize = rem*100*125/10000 + 'px'
        }
   
    }

    setRemUnit()

    // reset rem unit on page resize
    // 当页面展示或重新设置大小的时候，触发重新
    window.addEventListener('resize', setRemUnit)
    window.addEventListener('pageshow', function (e) {
        if (e.persisted) {
            setRemUnit()
        }
    })

}(window, document)